package com.hafu.dao;

import com.hafu.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDao {

    public Boolean isLogin(String username, String password) {
        //查询数据库，完成用户查询
        Connection conn = DbUtil.getConn();
        //查询用户表的sql
        String sql = "select * from userlist where name=? and pass=?";

        try {
            PreparedStatement preparedStatement = conn.prepareStatement(sql);
            preparedStatement.setString(1, username);
            preparedStatement.setString(2, password);
            ResultSet resultSet = preparedStatement.executeQuery();
            if (resultSet.next()){
                return true;
            }else return false;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


        return false;
    }
}
